package com.huawei.appgallery.purchasehistory.ui.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import huawei.widget.HwTextView;
import o.cjz;
import o.cst.b;
import o.cst.c;
import o.cst.g;
import o.cst.j;
import o.cts;
import o.ContentManager;
import o.epv;

public class ToolBarIcon extends LinearLayout {
    private TextView ˋ;

    public interface a {
        void ˋ(TextView textView, o.cts.a aVar);
    }

    public ToolBarIcon(Context context) {
        super(context);
        ˋ(context, null);
    }

    public ToolBarIcon(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(context, attributeSet);
    }

    public ToolBarIcon(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋ(context, attributeSet);
    }

    private void ˋ(Context context, AttributeSet attributeSet) {
        int dimensionPixelSize = getContext().getResources().getDimensionPixelSize(c.ˊ);
        setMinimumHeight(getContext().getResources().getDimensionPixelSize(c.ˏ));
        setPadding(dimensionPixelSize, 0, dimensionPixelSize, 0);
        View hwTextView = new HwTextView(context, attributeSet);
        hwTextView.setCompoundDrawablePadding(getContext().getResources().getDimensionPixelSize(c.ˋ));
        hwTextView.setEllipsize(TruncateAt.END);
        hwTextView.setTextAppearance(getContext(), g.ˊ);
        addView(hwTextView);
        setBackgroundResource(b.ˎ);
        if (attributeSet != null) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, j.ॱˉ);
            int indexCount = obtainStyledAttributes.getIndexCount();
            for (dimensionPixelSize = 0; dimensionPixelSize < indexCount; dimensionPixelSize++) {
                if (j.ॱˑ == obtainStyledAttributes.getIndex(dimensionPixelSize)) {
                    cts.ˎ.ˋ(hwTextView, o.cts.a.ˋ(obtainStyledAttributes.getInt(j.ॱˑ, 0)));
                    break;
                }
            }
            obtainStyledAttributes.recycle();
        }
        this.ˋ = hwTextView;
        cjz.ˎ(hwTextView);
    }

    public void setDisable(Drawable drawable) {
        if (drawable != null && this.ˋ != null) {
            int ˋ = epv.ˋ(ContentManager.getInstant().getContext(), 24);
            drawable.setBounds(0, 0, ˋ, ˋ);
            ˋ = getResources().getColor(o.cst.a.ˏ);
            this.ˋ.setCompoundDrawables(null, drawable, null, null);
            this.ˋ.setEnabled(false);
            this.ˋ.setTextColor(ˋ);
            setEnabled(false);
        }
    }
}
